import Vue from 'vue'
import Cookies from 'js-cookie'
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
import Element from 'element-ui'
import './styles/element-variables.scss'
import '@/styles/index.scss' // global css
import App from './App'
import store from './store'
import router from './router'
import './icons' // icon
import './permission' // permission control
import * as filters from './filters' // global filters
import permission from '@/directive/permission/index.js' // 权限判断指令
import Print from '@/utils/print' // 打印
import './../public/font_icon/iconfont.css'
import clipboard from 'vue-clipboard2'
import XEUtils from 'xe-utils'
import { encryptData, decryptData } from '@/utils/index'

Vue.use(clipboard)
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
Vue.prototype.$XEUtils = XEUtils
Vue.prototype.$ed = encryptData
Vue.prototype.$dd = decryptData
Vue.prototype.$parseImgUrl = (src) => {
  if (!src || src.length <= 0) {
    return null
  }
  if (src.toLowerCase().indexOf('http://') === 0 || src.toLowerCase().indexOf('https://') === 0) {
    return src
  }
  return process.env.VUE_APP_BASE_API + src
}
// 引入vue-amap
import VueAMap from 'vue-amap'
Vue.use(VueAMap)

// 百度地图
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  ak: 'R1wU2XdMCPYyNGm1Edi2O2SOQ1GRI7og'
})
Vue.use(Print)
Vue.use(Element, {
  size: Cookies.get('size') || 'medium' // set element-ui default size
})
Vue.directive('permission', permission)
// register global utility filters.
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
Vue.config.productionTip = false
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
